﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Survey.Entity;
using Survey.DataAccessLayer.Data;

namespace Survey.DataAccessLayer
{
    public class QuestionFeedbackAccessor : Accessor<QuestionFeedback>
    {
        public QuestionFeedbackAccessor() : base(new SurveyDbContext()) { }
        public QuestionFeedback GetQuestionFeedback(int id)
        {
            var q = Select(questionFeedback => questionFeedback.Id == id);
            return q.Single();
        }
        /// <summary>
        /// 获取问题的回答列表
        /// </summary>
        /// <param name="question"></param>
        /// <returns></returns>
        public IEnumerable<QuestionFeedback> GetQuestionFeedbacks(Question question)
        {
            var returnValue = new List<QuestionFeedback>();
            returnValue.AddRange(
                Select(
                    questionFeedback => questionFeedback.RefQuestionOption.QuestionId == question.Id));
            return returnValue;
        }
    }
}
